package com.tianqu.tms.entity;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.tianqu.tms.core.base.TmsEntity;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dao.TransferFinanceInfoDao;
import com.tianqu.tms.dto.AttnDto;
import com.tianqu.tms.dto.TransferFinanceInfoDto;
import com.tianqu.tms.dto.UserDto;

/**
 * 过户财务收费表
 * 
 * @author Administrator
 * 
 */
public class TransferFinanceInfo extends TmsEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5800514340783400356L;
    private int cssFlag;
	private int id;
	private String serial;
	private int checkPrice; // 流程表收费金额
	private int assessPrice; // 评估收费金额
	private int agencyPrice; // 代办收费金额
	private int extendedPrice; // 代办超期/过期收费金额
	private int expiredPrice; //
	private int transferPrice; // 过户费实收金额
	private int otherBackPrice; // 其他退办退费金额
	private int sdBackPrice; // 审档退办退费金额
	private int changePrice; // 变更交易票金额
	private int pzBackPrice;// 凭证退办费

	private Timestamp checkPriceDate;
	private Timestamp changePriceDate;
	private Timestamp backPriceDate;
	private int checkBackPrice;
	private Timestamp checkBackPriceDate;
	private int transferFlag;

	private int checkPriceUserId;// 流程表收费员ID
	private int agencyPriceUserId;// 待办收费员ID
	private int extendedPriceUserId;// 待办超期/过期收费员ID
	private int backPriceUserId;// 退办退费收费员ID
	private int changePriceUserId;// 变更交易票收费员ID
	private int checkBackPriceUserId;// 流程表退费收费员ID

	private String checkPrcieDate;
	private String transferPriceDate;

	private int transferPriceUserId;
	private String changePriceDates;
	private String agencyPriceDate;
	private Timestamp transferPriceDatet;
	private Timestamp agencyPriceDatet;
	private Timestamp extendedPriceDate;
	private int checkPriceChargeType;
	private int transferPriceChargeType;
	private int backChargeType;
	private int checkBackChargeType;
	private int agencyChargeType;
	private int count;
	/**
	 * 
	 */

	public static TransferFinanceInfo getInstance() {
		TransferFinanceInfo person = new TransferFinanceInfo();
		person.setExisting(false);
		return person;
	}

	/**
	 * 评估
	 * 
	 * @param finance
	 * @throws TmsDaoException
	 */
	public void updateFinanceInfoAtAssess(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);

		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();

		dto.setSerial(finance.getSerial());
		dto.setAssessPrice(finance.getAssessPrice());

		uDao.updateFinanceInfoAtAssess(dto);

	}

	/**
	 * 查验
	 * 
	 * @param finance
	 * @throws TmsDaoException
	 */
	public void updateFinanceInfoAtCheck(TransferFinanceInfo finance) throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setCheckPrice(finance.getCheckPrice());
		dto.setTransferPrice(finance.getTransferPrice());
		dto.setCheckPriceUserId(finance.getCheckPriceUserId());
		dto.setTransferPriceUserId(finance.getCheckPriceUserId());
		dto.setCheckPriceChargeType(finance.getCheckPriceChargeType());
		dto.setTransferPriceChargeType(finance.getTransferPriceChargeType());
		uDao.updateFinanceInfoAtCheck(dto);

	}

	/**
	 * 库存打印流程表
	 * 
	 * @param finance
	 * @throws TmsDaoException
	 */
	public void updateFinanceInfoAtMarket(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);

		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();

		dto.setSerial(finance.getSerial());
		dto.setCheckPrice(finance.getCheckPrice());
		dto.setTransferPriceFlag(finance.getTransferFlag());
		dto.setTransferPrice(finance.getTransferPrice());
		dto.setCheckPriceUserId(finance.getCheckPriceUserId());
		dto.setTransferPriceUserId(finance.getTransferPriceUserId());
		dto.setCheckPriceChargeType(finance.getCheckPriceChargeType());
		dto.setTransferPriceChargeType(finance.getTransferPriceChargeType());
		uDao.updateFinanceInfoAtMarket(dto);
	}

	/**
	 * 在打印流程表的时候往数据库中插入数据
	 * 
	 * @throws TmsDaoException
	 */
	public void insertProcedure(String serial) throws TmsDaoException {
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(serial);
		dto.setChangePrice(50);
		// dto.setChecktype(1);
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		if (uDao.insertProcedureFlag(serial)) {
			uDao.insertProcedure(dto);
		}

	}

	/**
	 * 新增入库中，生成最新数据（只有流水号）
	 * 
	 * @param serial
	 * @throws TmsDaoException
	 */
	public void insertFinanceByInner(String serial) throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		uDao.insertFinanceByInner(serial);

	}

	/**
	 * 将Dto信息set到entity中
	 * 
	 * @return
	 */
	public TransferFinanceInfo setEntityFromDto(TransferFinanceInfo entity,
			TransferFinanceInfoDto dto) {
		entity.setId(dto.getId());
		entity.setSerial(dto.getSerial());
		entity.setCheckPrice(dto.getCheckPrice());
		entity.setAssessPrice(dto.getAssessPrice());
		entity.setAgencyPrice(dto.getAgencyPrice());
		entity.setExtendedPrice(dto.getExtendedPrice());
		entity.setExpiredPrice(dto.getExpiredPrice());
		entity.setTransferPrice(dto.getTransferPrice());
		entity.setOtherBackPrice(dto.getOtherBackPrice());
		entity.setSdBackPrice(dto.getSdBackPrice());
		entity.setChangePrice(dto.getChangePrice());
		entity.setPzBackPrice(dto.getPzBackPrice());
		entity.setTransferPriceDate(DateUtil.getDateByTimeStampHM(dto.getTransferPriceDate()));
		entity.setCheckPrcieDate(DateUtil.getDateByTimeStampHM(dto.getCheckPriceDate()));
		entity.setChangePriceDates(DateUtil.getDateByTimeStampHM(dto.getChangePriceDate()));
		entity.setAgencyPriceDate(DateUtil.getDateByTimeStampHM(dto.getAgencyPriceDate()));
		entity.setCheckPriceChargeType(dto.getCheckPriceChargeType());
		entity.setTransferPriceChargeType(dto.getTransferPriceChargeType());
		entity.setBackChargeType(dto.getBackChargeType());
		return entity;
	}

	/**
	 * 根据流水号查询收费信息
	 * 
	 * @param serial2
	 * @return
	 * @throws TmsDaoException
	 */
	public TransferFinanceInfo findFinanceInfoByserial(String serial)
			throws TmsDaoException {
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		dto = uDao.findFinanceInfoByserial(serial);

		TransferFinanceInfo entity = new TransferFinanceInfo();
		if (dto != null) {
			entity = setEntityFromDto(entity, dto);
			return entity;
		}

		return null;
	}

	/**
	 *更新过户收费信息
	 * 
	 * @param finance
	 * @throws TmsDaoException
	 */

	public void updateFinanceInfoPrice(TransferFinanceInfo finance)
			throws TmsDaoException {
		// TODO Auto-generated method stub
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setCheckPrice(finance.getCheckPrice());
		dto.setAssessPrice(finance.getAssessPrice());
		dto.setAgencyPrice(finance.getAgencyPrice());
		dto.setExtendedPrice(finance.getExtendedPrice());
		dto.setTransferPrice(finance.getTransferPrice());
		dto.setOtherBackPrice(finance.getOtherBackPrice());
		dto.setSdBackPrice(finance.getSdBackPrice());
		dto.setChangePrice(finance.getChangePrice());
		dto.setPzBackPrice(finance.getPzBackPrice());
		dto.setBackChargeType(finance.getBackChargeType());
		dto.setAgencyChargeType(finance.getAgencyChargeType());
		uDao.updateFinanceInfoPrice(dto);

	}

	public void updateFinanceInfoAtReback(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setId(finance.getId());
		dto.setSerial(finance.getSerial());
		uDao.updateFinanceInfoAtReback(dto);
	}

	public void deleteFinanceInfoBySerial(String serial) throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		uDao.deleteFinanceInfoBySerial(serial);
	}

	public void updateTransferTime(TransferFinanceInfo finance) throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setTransferPriceUserId(finance.getTransferPriceUserId());
		uDao.updateTransferTime(dto);
	}

	public void updateTransferCheckBackPrice(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setCheckBackPrice(finance.getCheckBackPrice());
		dto.setCheckBackPriceUserId(finance.getCheckBackPriceUserId());
		dto.setCheckBackChargeType(finance.getCheckBackChargeType());
		uDao.updateTransferCheckBackPrice(dto);
	}

	public void updateChangePriceDate(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setChangePriceUserId(finance.getChangePriceUserId());
		uDao.updateChangePriceDate(dto);
	}

	public void updateBackPriceDate(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setBackPriceUserId(finance.getBackPriceUserId());
		uDao.updateBackPriceDate(dto);
	}

	public void updateExtendedPriceDate(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setExtendedPriceUserId(finance.getExtendedPriceUserId());
		uDao.updateExtendedPriceDate(dto);
	}

	public void updateAgencyPriceDate(TransferFinanceInfo finance)
			throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao
				.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setAgencyPriceUserId(finance.getAgencyPriceUserId());
		uDao.updateAgencyPriceDate(dto);
	}

	public List getChargeInfoByPeriod(String startDate,String endDate)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List list = uDao.getChargeInfoByPeriod(startDate,endDate);
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodLC(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodLC(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setCheckPrice(dto.getCheckPrice());
				entity.setCheckPriceUserId(dto.getCheckPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodJYP(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodJYP(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setTransferPrice(dto.getTransferPrice());
				entity.setTransferPriceUserId(dto.getTransferPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodDB(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodDB(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setAgencyPrice(dto.getAgencyPrice());
				entity.setAgencyPriceUserId(dto.getAgencyPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodDBOut(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodDBOut(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setExtendedPrice(dto.getExtendedPrice());
				entity.setExtendedPriceUserId(dto.getExtendedPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodBG(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodBG(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setChangePrice(dto.getChangePrice());
				entity.setChangePriceUserId(dto.getChangePriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodLCT(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodLCT(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setCheckBackPrice(dto.getCheckBackPrice());
				entity.setCheckBackPriceUserId(dto.getCheckBackPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}
	public List<TransferFinanceInfo> getFinaneInfoByPeriodJYPT(String startDate,String endDate,int userId)throws TmsDaoException
	{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfoDto> dtoList = uDao.getFinaneInfoByPeriodJYPT(startDate,endDate,userId);
		List<TransferFinanceInfo> list = null;
		if(dtoList!=null)
		{
			list = new ArrayList<TransferFinanceInfo>();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferFinanceInfoDto dto = (TransferFinanceInfoDto)dtoList.get(i);
				TransferFinanceInfo entity = new TransferFinanceInfo();
				entity.setOtherBackPrice(dto.getOtherBackPrice());
				entity.setSdBackPrice(dto.getSdBackPrice());
				entity.setPzBackPrice(dto.getPzBackPrice());
				entity.setBackPriceUserId(dto.getBackPriceUserId());
				entity.setCount(dto.getCount());
				list.add(entity);
			}
		}
		return list;
	}	
	public void insertFinanceInfo(TransferFinanceInfo financeInfo,int type,int checkPriceType)throws TmsDaoException{
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(financeInfo.getSerial());
		dto.setCheckPrice(financeInfo.getCheckPrice());
		dto.setCheckPriceChargeType(financeInfo.getCheckPriceChargeType());
		dto.setCheckPriceUserId(financeInfo.getCheckPriceUserId());
		dto.setTransferPrice(financeInfo.getTransferPrice());
		dto.setTransferPriceChargeType(financeInfo.getTransferPriceChargeType());
		dto.setTransferPriceUserId(financeInfo.getTransferPriceUserId());
		uDao.insertFinanceInfo(dto,type,checkPriceType);
	}
	public void updateFinanceInfoAtWXByCheckPrice(TransferFinanceInfo finance)throws TmsDaoException {	
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);				
		TransferFinanceInfoDto dto = new TransferFinanceInfoDto();
		dto.setSerial(finance.getSerial());
		dto.setCheckPrice(finance.getCheckPrice());
		dto.setCheckPriceUserId(finance.getCheckPriceUserId());
		dto.setCheckPriceChargeType(finance.getCheckPriceChargeType());	
		uDao.updateFinanceInfoAtWXByCheckPrice(dto);
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSerial() {
		return serial;
	}

	public void setSerial(String serial) {
		this.serial = serial;
	}

	public int getCheckPrice() {
		return checkPrice;
	}

	public void setCheckPrice(int checkPrice) {
		this.checkPrice = checkPrice;
	}

	public int getAssessPrice() {
		return assessPrice;
	}

	public void setAssessPrice(int assessPrice) {
		this.assessPrice = assessPrice;
	}

	public int getAgencyPrice() {
		return agencyPrice;
	}

	public void setAgencyPrice(int agencyPrice) {
		this.agencyPrice = agencyPrice;
	}

	public int getExtendedPrice() {
		return extendedPrice;
	}

	public void setExtendedPrice(int extendedPrice) {
		this.extendedPrice = extendedPrice;
	}

	public int getExpiredPrice() {
		return expiredPrice;
	}

	public void setExpiredPrice(int expiredPrice) {
		this.expiredPrice = expiredPrice;
	}

	public int getTransferPrice() {
		return transferPrice;
	}

	public void setTransferPrice(int transferPrice) {
		this.transferPrice = transferPrice;
	}

	public int getOtherBackPrice() {
		return otherBackPrice;
	}

	public void setOtherBackPrice(int otherBackPrice) {
		this.otherBackPrice = otherBackPrice;
	}

	public int getSdBackPrice() {
		return sdBackPrice;
	}

	public void setSdBackPrice(int sdBackPrice) {
		this.sdBackPrice = sdBackPrice;
	}

	public int getChangePrice() {
		return changePrice;
	}

	public void setChangePrice(int changePrice) {
		this.changePrice = changePrice;
	}

	public int getPzBackPrice() {
		return pzBackPrice;
	}

	public void setPzBackPrice(int pzBackPrice) {
		this.pzBackPrice = pzBackPrice;
	}

	@Override
	public void save() throws TmsDaoException, TmsException {
		// TODO Auto-generated method stub

	}

	public Timestamp getCheckPriceDate() {
		return checkPriceDate;
	}

	public String getTransferPriceDate() {
		return transferPriceDate;
	}

	public void setCheckPriceDate(Timestamp checkPriceDate) {
		this.checkPriceDate = checkPriceDate;
	}

	public void setTransferPriceDate(String transferPriceDate) {
		this.transferPriceDate = transferPriceDate;
	}

	public Timestamp getChangePriceDate() {
		return changePriceDate;
	}

	public void setChangePriceDate(Timestamp changePriceDate) {
		this.changePriceDate = changePriceDate;
	}

	public Timestamp getBackPriceDate() {
		return backPriceDate;
	}

	public void setBackPriceDate(Timestamp backPriceDate) {
		this.backPriceDate = backPriceDate;
	}

	public int getCheckBackPrice() {
		return checkBackPrice;
	}

	public int getAgencyChargeType() {
		return agencyChargeType;
	}

	public void setAgencyChargeType(int agencyChargeType) {
		this.agencyChargeType = agencyChargeType;
	}

	public void setCheckBackPrice(int checkBackPrice) {
		this.checkBackPrice = checkBackPrice;
	}

	public Timestamp getCheckBackPriceDate() {
		return checkBackPriceDate;
	}

	public void setCheckBackPriceDate(Timestamp checkBackPriceDate) {
		this.checkBackPriceDate = checkBackPriceDate;
	}

	public int getTransferFlag() {
		return transferFlag;
	}

	public void setTransferFlag(int transferFlag) {
		this.transferFlag = transferFlag;
	}

	public String getCheckPrcieDate() {
		return checkPrcieDate;
	}

	public void setCheckPrcieDate(String checkPrcieDate) {
		this.checkPrcieDate = checkPrcieDate;
	}

	public String getChangePriceDates() {
		return changePriceDates;
	}

	public void setChangePriceDates(String changePriceDates) {
		this.changePriceDates = changePriceDates;
	}

	public String getAgencyPriceDate() {
		return agencyPriceDate;
	}

	public void setAgencyPriceDate(String agencyPriceDate) {
		this.agencyPriceDate = agencyPriceDate;
	}

	public int getCheckPriceUserId() {
		return checkPriceUserId;
	}

	public void setCheckPriceUserId(int checkPriceUserId) {
		this.checkPriceUserId = checkPriceUserId;
	}

	public int getAgencyPriceUserId() {
		return agencyPriceUserId;
	}

	public void setAgencyPriceUserId(int agencyPriceUserId) {
		this.agencyPriceUserId = agencyPriceUserId;
	}

	public int getExtendedPriceUserId() {
		return extendedPriceUserId;
	}

	public void setExtendedPriceUserId(int extendedPriceUserId) {
		this.extendedPriceUserId = extendedPriceUserId;
	}

	public int getTransferPriceUserId() {
		return transferPriceUserId;
	}

	public void setTransferPriceUserId(int transferPriceUserId) {
		this.transferPriceUserId = transferPriceUserId;
	}

	public int getBackPriceUserId() {
		return backPriceUserId;
	}

	public void setBackPriceUserId(int backPriceUserId) {
		this.backPriceUserId = backPriceUserId;
	}

	public int getChangePriceUserId() {
		return changePriceUserId;
	}

	public void setChangePriceUserId(int changePriceUserId) {
		this.changePriceUserId = changePriceUserId;
	}

	public int getCheckBackPriceUserId() {
		return checkBackPriceUserId;
	}

	public void setCheckBackPriceUserId(int checkBackPriceUserId) {
		this.checkBackPriceUserId = checkBackPriceUserId;
	}

	public Timestamp getTransferPriceDatet() {
		return transferPriceDatet;
	}

	public int getCheckPriceChargeType() {
		return checkPriceChargeType;
	}

	public void setCheckPriceChargeType(int checkPriceChargeType) {
		this.checkPriceChargeType = checkPriceChargeType;
	}

	public int getTransferPriceChargeType() {
		return transferPriceChargeType;
	}

	public void setTransferPriceChargeType(int transferPriceChargeType) {
		this.transferPriceChargeType = transferPriceChargeType;
	}

	public int getCheckBackChargeType() {
		return checkBackChargeType;
	}

	public void setCheckBackChargeType(int checkBackChargeType) {
		this.checkBackChargeType = checkBackChargeType;
	}

	public void setTransferPriceDatet(Timestamp transferPriceDatet) {
		this.transferPriceDatet = transferPriceDatet;
	}

	public Timestamp getAgencyPriceDatet() {
		return agencyPriceDatet;
	}

	public void setAgencyPriceDatet(Timestamp agencyPriceDatet) {
		this.agencyPriceDatet = agencyPriceDatet;
	}

	public Timestamp getExtendedPriceDate() {
		return extendedPriceDate;
	}

	public void setExtendedPriceDate(Timestamp extendedPriceDate) {
		this.extendedPriceDate = extendedPriceDate;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getBackChargeType() {
		return backChargeType;
	}

	public void setBackChargeType(int backChargeType) {
		this.backChargeType = backChargeType;
	}

	
	private String no;//序号
	private String closePrice;//已结算金额
	private int priceType; //费用类型
	private String priceTypeStr;//费用类型
	private String total;//数量
	private String attnName;//经办人
	private String shortName;//所属商户
	private String transferType;//业务类型
	private String price;//金额
	private String realName;//操作员
	private String priceDate;//支付时间
	private String acceptedTime;//结算时间
	private String attnId;
	private String priceUserId;
	
	/**
	 * 已结算列表数据
	 * @param dateFrom  yyyyMMdd
	 * @param dateTo yyyyMMdd
	 * @return
	 */
	public TransferFinanceInfo findTransferfinanceList(String dateFrom, String dateTo) throws TmsDaoException {
		//
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfo> list = uDao.findTransferFinanceList(dateFrom, dateTo);
		int total = 0;
		int price = 0;
		int i = 1;
		for (TransferFinanceInfo info : list) {
			if (i%2 == 0){
				info.setCssFlag(1);
			} else{
				info.setCssFlag(2);
			}
			price = price + Integer.parseInt(info.getPrice());
			total = total + Integer.parseInt(info.getTotal());
			info.setNo(String.valueOf(i++));
		}
		TransferFinanceInfo info = new  TransferFinanceInfo();
		info.setDetailInfo(list);
		info.setPriceTypeStr("汇总合计");
		info.setTotal(String.valueOf(total));
		info.setClosePrice(String.valueOf(price));
		return info;
	}
	
	/**
	 * 详细数据
	 * @param dateFrom  yyyyMMdd
	 * @param dateTo yyyyMMdd
	 * @param type 0 未结算，1 已结算
	 * @param pType 费用类型
	 * @return
	 */
	public TransferFinanceInfo findTransferFinanceDeail(String dateFrom, String dateTo, int type, int pType) throws TmsDaoException {
		TransferFinanceInfoDao uDao = (TransferFinanceInfoDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_FINANCE_INFO);
		List<TransferFinanceInfo> list = new ArrayList<TransferFinanceInfo>();
		int price = 0;
		int i = 1;
		Attn attnManager = Attn.getInstance();
		User userManager = new User();
		Codes code = Codes.getInstance();
		Map<String, AttnDto> attnMap = attnManager.findAllAttn();
		Map<Long, UserDto> userMap = userManager.findAllUser();
		if(type == 1) {//已结算详细
			list = uDao.findTransferFinanceDeail1(dateFrom, dateTo, pType);
			for (TransferFinanceInfo info : list) {
				if (i%2 == 0){
					info.setCssFlag(1);
				} else{
					info.setCssFlag(2);
				}
				price = price + Integer.parseInt(info.getPrice());
				info.setNo(String.valueOf(i++));
				AttnDto attn = attnMap.get(info.getAttnId());
				if(attn != null) {
					info.setAttnName(attn.getAttnName());
					info.setShortName(attn.getShortName());
				}
				String transferType = info.getTransferType();
				if(StringUtils.isNotEmpty(transferType)) {
					info.setTransferType(code.getItemValueByItemIdAndItemCode(Codes.TRANSFER_TYPE, Integer.parseInt(transferType)));
				}
				int priceType = info.getPriceType();
				if(priceType==9) {
					info.setRealName(info.getAttnName());
				} else {
					info.setAcceptedTime(info.getPriceDate());
					String priceUserId = info.getPriceUserId();
					if(priceUserId != null) {
						UserDto user = userMap.get(Long.parseLong(priceUserId));
						if(user != null) info.setRealName(user.getRealName());
					}
				}
				info.setPriceTypeStr(code.getItemValueByItemIdAndItemCode(Codes.CHARGE_TYPE_CHARGE, priceType));
				if(StringUtil.isEmpty(info.getPriceTypeStr())) {
					info.setPriceTypeStr(code.getItemValueByItemIdAndItemCode(Codes.CHARGE_TYPE_REFUND, priceType));
				}
			}
		} else {//未结算详细
			list = uDao.findTransferFinanceDeail0(dateFrom, dateTo);
			for (TransferFinanceInfo info : list) {
				if (i%2 == 0){
					info.setCssFlag(1);
				} else{
					info.setCssFlag(2);
				}
				price = price + Integer.parseInt(info.getPrice());
				info.setNo(String.valueOf(i++));
				AttnDto attn = attnMap.get(info.getAttnId());
				if(attn != null) {
					info.setAttnName(attn.getAttnName());
					info.setShortName(attn.getShortName());
				}
				String transferType = info.getTransferType();
				if(StringUtils.isNotEmpty(transferType)) {
					info.setTransferType(code.getItemValueByItemIdAndItemCode(Codes.TRANSFER_TYPE, Integer.parseInt(transferType)));
				}
				int priceType = info.getPriceType();
				info.setPriceTypeStr(code.getItemValueByItemIdAndItemCode(Codes.CHARGE_TYPE_CHARGE, priceType));
				if(StringUtil.isEmpty(info.getPriceTypeStr())) {
					info.setPriceTypeStr(code.getItemValueByItemIdAndItemCode(Codes.CHARGE_TYPE_REFUND, priceType));
				}
				String priceUserId = info.getPriceUserId();
				if(priceUserId != null) {
					if(priceUserId.length() ==5 && priceUserId.substring(0, 1).equals("4")) {
						AttnDto tmp = attnMap.get(priceUserId);
						if(tmp != null) info.setRealName(tmp.getAttnName());
					} else {
						UserDto user = userMap.get(Long.parseLong(info.getPriceUserId()));
						if(user != null) info.setRealName(user.getRealName());
					}
				}
			}
		}
		
		TransferFinanceInfo info = new  TransferFinanceInfo();
		info.setDetailInfo(list);
		info.setPriceTypeStr("汇总合计");
		info.setTotal(String.valueOf(list.size()));
		info.setClosePrice(String.valueOf(price));
		return info;
	}
	
	/**
	 * 
	 */
	private List<TransferFinanceInfo> detailInfo;
	
	public List<TransferFinanceInfo> getDetailInfo() {
		return detailInfo;
	}

	public void setDetailInfo(List<TransferFinanceInfo> detailInfo) {
		this.detailInfo = detailInfo;
	}

	public String getPriceUserId() {
		return priceUserId;
	}

	public void setPriceUserId(String priceUserId) {
		this.priceUserId = priceUserId;
	}

	public String getAttnId() {
		return attnId;
	}

	public void setAttnId(String attnId) {
		this.attnId = attnId;
	}

	public String getAttnName() {
		return attnName;
	}

	public void setAttnName(String attnName) {
		this.attnName = attnName;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public String getTransferType() {
		return transferType;
	}

	public void setTransferType(String transferType) {
		this.transferType = transferType;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getPriceDate() {
		return priceDate;
	}

	public void setPriceDate(String priceDate) {
		this.priceDate = priceDate;
	}

	public String getAcceptedTime() {
		return acceptedTime;
	}

	public void setAcceptedTime(String acceptedTime) {
		this.acceptedTime = acceptedTime;
	}

	public String getClosePrice() {
		return closePrice;
	}

	public void setClosePrice(String closePrice) {
		this.closePrice = closePrice;
	}

	public int getPriceType() {
		return priceType;
	}

	public void setPriceType(int priceType) {
		this.priceType = priceType;
	}

	public String getPriceTypeStr() {
		return priceTypeStr;
	}

	public void setPriceTypeStr(String priceTypeStr) {
		this.priceTypeStr = priceTypeStr;
	}

	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}

	public String getTotal() {
		return total;
	}

	public void setTotal(String total) {
		this.total = total;
	}

	public int getCssFlag() {
		return cssFlag;
	}

	public void setCssFlag(int cssFlag) {
		this.cssFlag = cssFlag;
	}
	
}
